package com.ssm.admin.controller;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ssm.admin.entity.dto.SaleOrderDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.ssm.admin.entity.SsmSodetailsEntity;
import com.ssm.admin.service.SsmSodetailsService;
import com.ssm.common.utils.PageUtils;
import com.ssm.common.utils.R;



/**
 * 
 *
 * @author ssm
 * @email sunlightcs@gmail.com
 * @date 2023-03-19 17:30:08
 */
@RestController
@RequestMapping("admin/ssmsodetails")
public class SsmSodetailsController {
    @Autowired
    private SsmSodetailsService ssmSodetailsService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = ssmSodetailsService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
		SsmSodetailsEntity ssmSodetails = ssmSodetailsService.getById(id);

        return R.ok().put("ssmSodetails", ssmSodetails);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody SsmSodetailsEntity ssmSodetails){
		ssmSodetailsService.save(ssmSodetails);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody SsmSodetailsEntity ssmSodetails){
		ssmSodetailsService.updateById(ssmSodetails);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
		ssmSodetailsService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

    /**
     * 后台查询销售订单详情
     */

    @GetMapping("findOrderInfoById/{id}")
    public R findOrderInfoById(@PathVariable("id") Integer id){
        List<SaleOrderDto> saleOrderDtoList = ssmSodetailsService.findOrderInfoById(id);
        HashMap<String, Object> map=new HashMap<>();
        map.put("saleOrderDtoList",saleOrderDtoList);

        return R.ok(map);
    }

}
